home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / fifo11.zip / FIFO.DOC < prev    next >
Text File  |  1991-04-23  |  6KB  |  139 lines

  1. The 16550A UART
  2.  
  3. by Randol Tigrett
  4.  
  5. If your computer includes a 16550A UART, chances are you'll get faster 
  6. throughput during your communications sessions if your software takes 
  7. advantage of it. To experiment with the UART in your machine, you can 
  8. use the DEBUG script shown in Figure 1 to generate a small program 
  9. called FIFO.COM. You simply run FIFO.COM once when you turn on your PC 
  10. and it activates the FIFO buffers in the UART, displaying what type of 
  11. UART you have in your machine, 8250 or 16550 or 16550A.
  12.      We emphasize the word experiment because some communications 
  13. programs, written before the introduction of the 16550A, might lock up 
  14. when the UART activates the previously unused upper bits of the 
  15. Interrupt ID Register. Even if your communications software doesn't 
  16. lock up with the FIFO buffer activated (and most don't) you still 
  17. won't get the full benefit of the FIFO buffer unless the program makes 
  18. use of it. 
  19.     Programs not specifically written for the 16550A won't move 
  20. data in large blocks the way more modern programs do, and FIFO.COM 
  21. can't make your communications program recognize the UART or utilize 
  22. its FIFO buffer better. However, activating the buffer with FIFO.COM 
  23. can potentially eliminate problems of overrunning the UART, 
  24. particularly in a PC on the receiving side of a high-throughput file 
  25. transfer. Although it may help in this way, FIFO.COM mainly 
  26. demonstrates how programmers can activate the buffer.
  27.     The NS16550AF UART (Universal Asychronous 
  28. Receiver/Transmitter) contains two 16-byte FIFO (first in, first out) 
  29. buffers. Slower machines, like an 8-MHz AT, using fast modems need 
  30. these buffers, as do faster machines, like a 33-MHz 386, that attempt 
  31. to run other programs in a multitasking mode while using asynchronous 
  32. communications. The interrupts generated by communications sessions 
  33. can have a serious impact on the effectiveness of computers running 
  34. multitasking operations. Programs in other sessions suspend 
  35. processing, displays don't update, and characters typed at the 
  36. keyboard don't register while the CPU services the UART.
  37.     The 16-byte FIFO buffers reduce the interrupt activity of the 
  38. CPU because they can hold more data before generating an interrupt 
  39. requesting a transfer. This makes it easier for slower CPUs to avoid 
  40. dropping characters when they receive a fast stream of data. You can 
  41. set the receive FIFO buffer to receive 1, 4, 8, or 14 characters 
  42. before the UART generates an interrupt.
  43.     If your computer contains a 16550 UART instead of the 16550A 
  44. or AF, be aware that the plain 16550 was flawed and will not work 
  45. correctly if the FIFO buffers are activated. When you buy a new 
  46. computer, make sure the manufacturer either sockets the UART or 
  47. installs the new 16550A UART. If you can install the UART yourself, it 
  48. costs only about $12. The 16550A UART is especially useful for 
  49. communicating with high-speed modems because, with the advent of 
  50. V.32bis modems, you can now enjoy a carrier rate of 14,400 bits per 
  51. second between modems. With V.42bis data compressions of 4 to 1, you 
  52. must set the DTE (Data Terminal Equipment) speed of the RS-232C link 
  53. to 57,600 bps for optimum performance during file transfers. Slower 
  54. PCs cannot handle the high RS-232C DTE speed without the 16550A UART.
  55.     If you want more information on programming the 16550A UART, 
  56. National Semiconductor makes available a book called Data 
  57. Communications: Local Area Networks: UARTs. The book sells for $10 and 
  58. you can call National Semiconductor at 408-721-5000 to ask about its 
  59. availability.
  60.  
  61. HOW TO GET FIFO.COM
  62. You can download FIFO.COM from library 2 of PC MagNet's Utilforum/Tips 
  63. forum (type GO PCM:TIPS from PC MagNet or CompuServe to get there) or 
  64. create it using the DOS DEBUG program.
  65.     Assuming DEBUG is available in the C: root directory, redirect 
  66. the following text to DEBUG by typing 
  67.  
  68. c:\debug <fifo.scr
  69.  
  70. The text below contains comments to illustrate the program's 
  71. operation. Remove all comments enclosed in /* */ before redirecting to 
  72. DEBUG. Note that this program will cause the 16550 UART to work 
  73. improperly by enabling its flawed FIFO buffer.
  74.  
  75. A
  76. JMP     0123
  77. NOP
  78. AND     [BX+DI],DH
  79. SS:
  80. XOR     AX,3035
  81. AND     [DI+41],DL
  82. PUSH    DX
  83. PUSH    SP
  84. AND     [BX+SI],AH
  85. AND     [BX+SI],AH
  86. AND     AL,20
  87. CMP     [BP+SI],DH
  88. XOR     AX,2030
  89. PUSH    BP
  90. INC     CX
  91. PUSH    DX
  92. PUSH    SP
  93. AND     [BX+SI],AH
  94. AND     [BX+SI],AH
  95. AND     [SI],AH
  96. MOV     DX,03F8     /* PORT ADDRESS - 0040:0000 */
  97. ADD     DX,+02      /* set offset to IIR Register */
  98. MOV     AL,C1       /* set receive buffer to 14 and enable */
  99. OUT     DX,AL       /* change the 14 = 0x0C to 1,4,or 8 */
  100. XOR     AX,AX
  101. IN      AL,DX
  102. PUSH    AX
  103. AND     AL,C0       /* set up for 16550A UART */
  104. CMP     AL,C0       /* is it a 16550A ?       */
  105. JNZ     013D        /* no                     */
  106. LEA     DX,[0103]   /* yes                    */
  107. JMP     0141
  108. NOP
  109. LEA     DX,[0113]   /* print either 16550 or 8250 */
  110. MOV     AH,09
  111. INT     21
  112. POP     AX
  113. MOV     AH,4C       /* show the IIR setup as errorlevel */
  114. INT     21
  115. RET
  116.  
  117. N FIFO.COM
  118. RCX
  119. 4B
  120. W
  121. Q
  122.  
  123. Figure 1: DEBUG script to generate FIFO.COM, a program that activates
  124. the 16550A UART's FIFO buffer and identifies the type of UART in your 
  125. machine.
  126. ===============================================
  127. Toad Hall Note:
  128.  
  129. The above horribleness can be circumvented by using the new FIFO.ASM
  130. I just produced with a *real* disassembly of FIFO.COM.
  131.  
  132. And if you want something a wee bit more sophisticated, look at
  133. UARTTYPE.ASM (with its accompanying UARTTYPE.MSG).  It not only activates
  134. the UART, but specifically identifies just which one it is!
  135.  
  136. David Kirschbaum
  137. Toad Hall
  138. kirsch%maxemail@uunet
  139.